package ca.llsutherland.squash.domain.helper;

import ca.llsutherland.squash.domain.Administrator;
import ca.llsutherland.squash.domain.Clock;
import ca.llsutherland.squash.domain.Shoe;
import ca.llsutherland.squash.exceptions.ValidationException;
import ca.llsutherland.squash.utils.ErrorConstants;

public class ShoesHelper {

    public static Shoe createNewShoe(String brand, String model, Clock dateCreated, Clock dateUpdated, Administrator createdBy, Long id) {
        Shoe shoe = createUnpersistedShoe(brand, model, dateCreated, dateUpdated, createdBy);
        shoe.setId(id);
        return shoe;
    }

    public static Shoe createUnpersistedShoe(String brand, String model, Clock dateCreated, Clock dateUpdated, Administrator createdBy) {
        Shoe shoe = new Shoe();
        shoe.setBrand(brand);
        shoe.setModel(model);
        shoe.setDateCreated(dateCreated);
        shoe.setDateUpdated(dateUpdated);
        shoe.setCreatedBy(createdBy);
        return shoe;
    }

    public static void assertNewValid(Shoe shoe) {
        DomainObjectHelper.assertNotNullWithErrorMessage(shoe, ErrorConstants.NULL_SHOES_ERROR);
        NamedDomainObjectHelper.assertValidName(shoe.getBrand());
        NamedDomainObjectHelper.assertValidName(shoe.getModel());
        if(shoe.getCreatedBy() == null) {
            throw new ValidationException(ErrorConstants.NULL_ADMINISTRATOR_ERROR);
        }
        
    }


}
